package org.adream.account.controller;

import java.util.Map;

import org.adream.account.aop.annotation.MonitorRequest;
import org.adream.account.entity.RealNameTmpEntity;
import org.adream.account.entity.RoleEntity;
import org.adream.account.entity.UserVerifyEntity;
import org.adream.account.service.ADreamServiceException;
import org.adream.account.service.RealNameTmpService;
import org.adream.account.service.RoleService;
import org.adream.account.service.UserVerifyService;
import org.adream.account.util.Constant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * "身份认证"管理模块 跳转controller
 * @author sl
 *
 */
@Controller
public class UserVerifyController {
	
	private final static Logger logger = LoggerFactory.getLogger(UserVerifyController.class);
	
	@Autowired
	private UserVerifyService verifyService;
	
	@Autowired
	private RealNameTmpService tmpService;
	
	@Autowired
	private RoleService roleService;
	
	@RequestMapping(value = "/verifyPage")
	public ModelAndView verifyPage() {
		ModelAndView mv = new ModelAndView("/verify/verify");
		return mv;
	}
	
	@RequestMapping(value = "/verifyAddPage")
	public ModelAndView verifyAdd() {
		ModelAndView mv = new ModelAndView("/verify/verify_add");
		return mv;
	}
	
	@RequestMapping(value = "/verifyEditPage")
	@MonitorRequest
	public ModelAndView verifyEdit(String uid,String rleId) {
		ModelAndView mv = new ModelAndView();
		RealNameTmpEntity realNameTmp = tmpService.queryTmpByUid(uid);
		RoleEntity role = roleService.queryRoleByRleId(rleId);
		UserVerifyEntity verify = verifyService.queryVerifiesByUidAndRleIdAndDr(uid, rleId, Constant.ONE);
		verify.setRealNameTmp(realNameTmp);
		verify.setRole(role);
		
		Map<String, Object> map = mv.getModel();
		
		String viewName = "/verify/";
		//获取"身份认证"排序值
		Integer sort = verify.getSort();
		switch (sort) {
		case 1:
			viewName += "teacher_verify_edit";		//梦想教师认证
			break;
		case 2:
			viewName += "vol_verify_edit";			//志愿者认证
			break;
		case 3:
			viewName += "adream_verify_edit";
			break;
		//case 4: 舍弃了 排序4
		case 11:
		case 12:
		case 13:
		case 14:
			viewName += "coach_plan_verify_edit";
			break;
		case 5: 
			viewName += "student_verify_edit"; //学生认证
			break;
		case 6: 
			viewName += "gfa_teacher_verify_edit"; //去远方-教师 认证
			break;
		case 7: 
			viewName += "gfa_student_verify_edit"; //去远方-学生认证
			break;
		case 8: 
		case 9: 
			viewName += "gfa_vol_verify_edit"; //去远方-评审志愿者认证//去远方-出行志愿者认证
			break;
		case 10:
			viewName += "community_edit";	//社区中心认证 (企业版)
			break;
			
		case 15:
			viewName += "sports_class_edit";	//运动梦想课
			break;	
			
		case 20:
			viewName += "county_adream_center_edit";	//社区中心认证 (企业版)
			break;
		case 101:
			viewName += "business_verify_edit";		//企业认证
			break;
		case 102:
			viewName += "gov_verify_edit";			//政府认证
			break;
		case 103:
			viewName += "org_verify_edit";			//社会组织认证
			break;
		case 104:
			viewName += "specialFund_verify_edit";	//专项基金认证
			break;
		case 105:
			viewName += "publicWelfareTeam_edit";	//专项基金认证
			break;
		}
		mv.setViewName(viewName);
		map.put("verify", verify);
		return mv;
	}
}